package com.open.ssm;

import java.util.Arrays;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * ApplicationRunner是在应用容器启动之后会回调到，在ApplicationStartedListener调用之后被调用。
 * 如果说ApplicationListener中有阻塞，那么ApplicationRunner也都不会被调用。
 * 实现ApplicationRunner接口，执行顺序按照value值决定，值小先执行。
 *
 * @version: v1.0.0
 * @author: wangpf
 * @date: 2022年11月28日 下午8:54:27
 */
@Component
//@Order(value=2)
public class OpenSSMApplicationRunner implements ApplicationRunner {
	
	private Logger logger = LoggerFactory.getLogger(OpenSSMApplicationRunner.class);
    
    @Override
    public void run(ApplicationArguments args) throws Exception {
    	//String strArgs = Arrays.stream(arg0.getSourceArgs()).collect(Collectors.joining("|"));
    	String[] sourceArgs = args.getSourceArgs();
    	String strArgs = Arrays.stream(sourceArgs).collect(Collectors.joining("|"));
    	logger.info("OpenSSMApplicationRunner --> args = " + strArgs);
    }
}
